﻿@model Tasker.WebUI.Models.Task.TaskShowModel
           
@{
    ViewBag.Title = Model.Name;
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section Sidebar
{
    <div class="p">
        <div class="label">
            <span>Статус:&nbsp;</span>
            <br><br>
        </div>
        <span class="status">
            @Model.Status
        </span>
        <br />
        <div class="clear"></div>
    </div>
    
    <div class="p">
        <div class="label">
            <span>Дедлайн</span>
            <br><br>
        </div>
        <span class="status">
            @Model.FinishDate
        </span>
        <br />
        <div class="clear"></div>
    </div>
    
    <div class="p">
        <div class="label">
            <span>Создано</span>
            <br><br>
        </div>
        <span class="status">
            @Model.CreatedDate
        </span>
        <br />
        <div class="clear"></div>
    </div>
    
    @if(Model.ParentId > 0)
    {
        <div class="p">
            <h4>Надзадача</h4>
            
            <div class="status">
                <a href="@Url.Action("Index","Task", new {id=@Model.ParentId})">
                    @Model.ParentTaskName
                </a>
            </div>
        </div>
    }
    
    <div class="p">
        <h4>Постановщик</h4>
        <div>
            <a class="sdf-link-to" href="@Url.Action("ShowProfile", "Staff", new { id = Model.AuthorId })">
                @Model.AuthorFullName
            </a>				
            <div class="lower">@Model.AuthorPosition</div>
        </div>
    </div>
    
    <div class="p">
        <h4>Ответственныe</h4>
        @foreach (var tw in Model.TaskWorkers)
        {
            <div>
                <a class="sdf-link-to" href="@Url.Action("ShowProfile", "Staff", new { id = tw.Id })">
                    @tw.FullName
                </a>				
                <div class="lower">
                    @tw.Position
                </div>
            </div>
        }
    </div>
}

@if (Model.AuthorNick == ViewBag.CurrentUserNick)
{
    <a href="@Url.Action("Edit", "Task")" class="act-edit-card">
            Редактировать задачу
        </a>
    <div style="overflow: hidden;padding: 10px 0;">
        
         @if (Model.StatusId != 4)
         {
              using (Html.BeginForm("Complete", "Task", FormMethod.Post))
              {
                  <input type="hidden" name="id" value="@Model.Id"/>
                  <a href="javascript:;" onclick="$(this).parents('form').submit();" class="btn" style="float: left; margin-right: 10px;">
                      Завершить
                  </a>
              }
              if (Model.StatusId != 3)
              {
                   using (Html.BeginForm("Stop", "Task", FormMethod.Post))
                   {
                       <input type="hidden" name="id" value="@Model.Id"/>
                       <a href="javascript:;" onclick="$(this).parents('form').submit();" class="btn" style="float: left;">
                           Приостановить
                       </a>
                   }
              }
              else
              {
                   using (Html.BeginForm("InProccess", "Task", FormMethod.Post))
                   {
                       <input type="hidden" name="id" value="@Model.Id"/>
                       <a href="javascript:;" onclick="$(this).parents('form').submit();" class="btn" style="float: left;">
                           Восстановить
                       </a>
                   }
              }
         }

        @using (Html.BeginForm("Delete", "Task", FormMethod.Post))
        {
            <input type="hidden" name="id" value="@Model.Id"/>
            <a href="javascript:;" onclick="$(this).parents('form').submit();" class="btn btn-danger" style="float: right;">
                Удалить
            </a>
        }
    </div>
}

<h1>@Model.Name</h1>

<div class="task-statement">
    <b>Суть задачи</b>
    <div class="task-card-statement">
        <p>
            @Model.Description
        </p>
    </div>
</div>
